<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2020/7/5
  Time: 15:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <title>Title</title>
    <%@include file="/common/com.jsp"%>
</head>
<body>
<div id="root">

    <card>
        <i-button type="dashed" shape="circle" @click="getLinkmanList()"><Icon type="ios-refresh"></Icon>刷新</i-button>
<shiro:hasPermission name="contacts:add">
        <i-button type="dashed" @click="add">添加</i-button>
</shiro:hasPermission>
    </card>

    <i-table :columns="columns" :data="data" border stripe height="400">
        <template slot-scope="{row,index}" slot="action">
<shiro:hasPermission name="contacts:update">
            <i-Button type="dashed" @click="update(row,index)">修改</i-Button>
</shiro:hasPermission>
<shiro:hasPermission name="contacts:del">
            <i-Button type="dashed" @click="del(row,index)">删除</i-Button>
</shiro:hasPermission>
        </template>
    </i-table>



    <Modal v-model="modaladd"  title="添加供应商联系人" @on-ok="doadd">
        <i-form :label-width="80">
            <Form-Item label="供应商名称">
                <i-input v-model="linkman.supperName"></i-input>
            </Form-Item>
            <Form-Item label="经济类型">
                <i-input v-model="linkman.supperEconomictype"></i-input>
            </Form-Item>
            <Form-Item label="行业类型">
                <i-input v-model="linkman.supperIndustrytype"></i-input>
            </Form-Item>
            <Form-Item label="联系人">
                <i-input v-model="linkman.supperUsername"></i-input>
            </Form-Item>
            <Form-Item label="电话">
                <i-input v-model="linkman.supperPhone"></i-input>
            </Form-Item>
            <Form-Item label="邮箱">
                <i-input v-model="linkman.supperEmail"></i-input>
            </Form-Item>
            <Form-Item label="介绍">
                <i-input v-model="linkman.supperDesc"></i-input>
            </Form-Item>
        </i-form>
    </Modal>

    <Modal v-model="modalupdate"  title="修改联系人" @on-ok="doupdate">
        <i-form :label-width="80">
            <Form-Item label="供应商名称">
                <i-input v-model="linkman.supperName"></i-input>
            </Form-Item>
            <Form-Item label="经济类型">
                <i-input v-model="linkman.supperEconomictype"></i-input>
            </Form-Item>
            <Form-Item label="行业类型">
                <i-input v-model="linkman.supperIndustrytype"></i-input>
            </Form-Item>
            <Form-Item label="联系人">
                <i-input v-model="linkman.supperUsername"></i-input>
            </Form-Item>
            <Form-Item label="电话">
                <i-input v-model="linkman.supperPhone"></i-input>
            </Form-Item>
            <Form-Item label="邮箱">
                <i-input v-model="linkman.supperEmail"></i-input>
            </Form-Item>
            <Form-Item label="介绍">
                <i-input v-model="linkman.supperDesc"></i-input>
            </Form-Item>
        </i-form>
    </Modal>




    <template>
        <Page :total="total"
              show-elevator
              :page-size="pageSize"
              style="margin-left: 340px;margin-top:15px"
              :current.sync="pageNo"
              show-sizer
              prev-text="上一页"
              next-text="下一页"
              :page-size-opts="[5,10,20,30,40]"
              show-total
              @on-page-size-change="pageSize=arguments[0];getLinkmanList();"
              @on-change="getLinkmanList"/>
    </template>
</div>
</body>
<script>
    new  Vue({
        el:"#root",
        data:{
            columns:[
                {title:"供应商名称",key:"supperName"},
                {title:"经济类型",key:"supperEconomictype"},
                {title:"行业类型",key:"supperIndustrytype"},
                {title:"联系人",key:"supperUsername"},
                {title:"电话",key:"supperPhone"},
                {title:"邮箱",key:"supperEmail"},
                {title:"介绍",key:"supperDesc"},
                {title:"其他操作",slot:"action"}
            ],
            data:[],
            LinkmanList:[],
            total:50,
            pageNo:1,
            pageSize:5,
            modaladd:false,
            modalupdate:false,
            modaladdissue:false,
            linkman:{},
            supperVo:{},


        },
        mounted(){
            this.getLinkmanList();
        },
        methods:{
            getLinkmanList(){
                axios.get(`${apath}/linkman/pagelist/${this.pageSize}/${this.pageNo}`,{params:this.supperVo})
                    .then(({data})=>{
                        console.log(data.result);
                        this.data=data.result.record;
                        this.total=data.result.total;
                    })
            },
            del(row,index){
                let _this=this;
                iview.Modal.confirm({
                    title:"是否确定删除?",
                    content:"此操作一旦确定无法返回,请谨慎使用",
                    onOk(){
                        axios.get(`${apath}/linkman/linkmandel/${row.id}`)
                            .then(({data})=>{
                                iview.Message.success({content: data.msg})
                                _this.getLinkmanList();
                            })
                    }
                })
            },

            add(){
                this.linkman = {};
                this.modaladd=true;
            },
            doadd(){
                axios.post(`${apath}/linkman/linkmanadd`,this.linkman)
                    .then(({data})=>{
                        alert("添加成功")
                        iview.Message.success({content:data.msg})
                        this.getLinkmanList();
                    })
            },

            update(row,index){
                this.linkman = row;
                this.modalupdate=true;

            },

            doupdate(){
                axios.post(`${apath}/linkman/linkmanupdate`,Qs.parse(params))
                    .then(({data})=>{
                        alert("修改成功")
                        iview.Message.success({content:data.msg})
                        this.getLinkmanList();
                    })
            },


        }
    })
</script>
</html>
